// 我们如果在一个动作中多次去改变 mutation 那么往往会封装一个 action
import Vue from 'vue'
import { getUserInfo } from 'api'

export const test1 = function ({commit}, uid) {
  commit('SET_UID', uid)
}

export const test2 = function ({commit}, phone) {
  commit('SET_PHONE', phone)
}

export const test3 = function ({commit}, area) {
  commit('SET_AREA', area)
}

export const getTokenInfo = function ({commit}, tokenInfo) {
  return getData().then(data=>{
    let {phone, area} = data
    commit('SET_PHONE', phone)
    commit('SET_AREA', area)
    commit('SET_TOKENINFO', data)
  })

}

export const test4 = function ({commit}, shopToken) {
  commit('SET_SHOPTOKEN', shopToken)
}


async function getData(){
  try {
    let {data} =  await getUserInfo()
      return  data
  }catch (e) {

    Vue.prototype.$warn(e.info)

  }
}
